@@ -75,6 +75,10 @@ module Agents |
||
| 75 | 75 |
if response['Response'].present? and response['Response'] == "Not authorized" |
| 76 | 76 |
raise StandardError, response['Response'] |
| 77 | 77 |
end |
| 78 |
+ if not response['id'].present? |
|
| 79 |
+ puts response |
|
| 80 |
+ raise StandardError, "Invalid response from Boxcar: #{response}"
|
|
| 81 |
+ end |
|
| 78 | 82 |
end |
| 79 | 83 |
end |
| 80 | 84 |
end |
@@ -37,17 +37,17 @@ describe Agents::BoxcarAgent do |
||
| 37 | 37 |
end |
| 38 | 38 |
|
| 39 | 39 |
describe "#receive" do |
| 40 |
- |
|
| 41 | 40 |
it "sends a message" do |
| 42 |
- stub(HTTParty).post '{
|
|
| 43 |
- "id":843878764, |
|
| 44 |
- "message":"blah", |
|
| 45 |
- "title":"blah", |
|
| 46 |
- "source_name":"Huginn" |
|
| 47 |
- }' |
|
| 41 |
+ stub(HTTParty).post { {"id" => 1, "message" => "blah", "title" => "blah","source_name" => "Custom Notification"} }
|
|
| 48 | 42 |
@checker.receive([@event]) |
| 49 | 43 |
end |
| 50 | 44 |
|
| 45 |
+ it "should raise error when invalid response arrives" do |
|
| 46 |
+ stub(HTTParty).post { {"blah" => "blah"} }
|
|
| 47 |
+ @checker.receive([@event]) |
|
| 48 |
+ expect{@checker.send_notification}.to raise_error
|
|
| 49 |
+ end |
|
| 50 |
+ |
|
| 51 | 51 |
it "should raise error when response says unauthorized" do |
| 52 | 52 |
stub(HTTParty).post '{"Response":"Not authorized"}'
|
| 53 | 53 |
expect{@checker.send_notification}.to raise_error
|